<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="header.jsp" %>
    <h1>我的博客</h1>
    <a href="${pageContext.request.contextPath}/write-blog.jsp" class="btn" style="margin-bottom: 20px;">写新博客</a>

    <c:forEach items="${myBlogs}" var="blog">
        <div style="background: white; padding: 20px; margin-bottom: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
            <h2><a href="${pageContext.request.contextPath}/blog/detail?id=${blog.id}" style="color: #2c3e50; text-decoration: none;">${blog.title}</a></h2>
            <p style="color: #7f8c8d; margin: 10px 0;">发布于: <fmt:formatDate value="${blog.createdAt}" pattern="yyyy-MM-dd"/> | 浏览量: ${blog.viewCount}</p>
            <div style="display: flex; justify-content: space-between; margin-top: 15px;">
                <div>
                    <a href="${pageContext.request.contextPath}/blog/edit?id=${blog.id}" class="btn">编辑</a>
                    <a href="${pageContext.request.contextPath}/blog/delete?id=${blog.id}" class="btn" style="background-color: #e74c3c;" onclick="return confirm('确定要删除这篇博客吗？')">删除</a>
                </div>
            </div>
        </div>
    </c:forEach>

    <c:if test="${empty myBlogs}">
        <p style="text-align: center; margin: 50px 0;">你还没有发表过博客</p>
    </c:if>
<%@ include file="footer.jsp" %>